package com.cc.service.impl;

import com.cc.mapper.NewsMapper;
import com.cc.model.EbNews;
import com.cc.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl implements NewsService {
    @Autowired
    private NewsMapper newsMapper;
    @Override
    public List <EbNews> list (int page, int pageSize) {
        return newsMapper.listByPage((page-1)*pageSize,pageSize);
    }

    @Override
    public int save(EbNews ebNews){
        return newsMapper.save(ebNews);
    }

    @Override
    public int deleteByPk(int enId){
        return newsMapper.delete(enId);
    }

    @Override
    public EbNews selectByCondition(Integer enId){
        return newsMapper.findById(enId);
    }

    @Override
    public int updateById(EbNews ebNews){
        return newsMapper.updateByPrimaryKey(ebNews);
    }

    @Override
    public int getMaxPage(int pageSize) {
        return newsMapper.getMaxPage(pageSize);
    }
}
